package kr.pe.johnkim.carrotpoint.mobile.dao;

import kr.pe.johnkim.carrotpoint.mobile.domain.CarrotPointBank;
import org.mybatis.spring.support.SqlSessionDaoSupport;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Carrot Point 거래 은행 관련 dao 클래스 이다.
 *
 * @author : John_Kim <cale9797@gmail.com>
 * @date : 13. 2. 6.
 */
@Repository
public class CarrotPointBankDaoImpl extends SqlSessionDaoSupport implements CarrotPointBankDao {

    // SLF4J Logging
    private Logger logger = LoggerFactory.getLogger(CarrotPointBankDaoImpl.class);

    /**
     * 거래 은행을 등록 한다.
     *
     * @param carrotPointBank
     */
    @Override
    public void registerBank(CarrotPointBank carrotPointBank) {
        logger.info("registerBank");
        this.getSqlSession().insert("CARROTPOINT_BANK.registerBank", carrotPointBank);
    }

    /**
     * 거래 은행 목록을 가져 온다.
     *
     * @param carrotPointBank
     * @return
     */
    @Override
    public List<CarrotPointBank> getBankList(CarrotPointBank carrotPointBank) {
        logger.info("getBankList");
        return this.getSqlSession().selectList("CARROTPOINT_BANK.getBankList", carrotPointBank);
    }

    /**
     * 거래 은행 정보를 가져 온다.
     *
     * @param carrotPointBank
     * @return
     */
    @Override
    public CarrotPointBank getBankInformation(CarrotPointBank carrotPointBank) {
        logger.info("getBankInformation");
        return (CarrotPointBank)getSqlSession().selectOne("CARROTPOINT_BANK.getBankInformation", carrotPointBank);
    }

    /**
     * 거래 은행 정보를 업데이트 한다.
     *
     * @param carrotPointBank
     */
    @Override
    public void updateBankInformation(CarrotPointBank carrotPointBank) {
        logger.info("updateBankInformation");
        this.getSqlSession().update("CARROTPOINT_BANK.updateBankInformation", carrotPointBank);
    }

    /**
     * 거래 은행 활성화 여부를 업데이트 한다.
     *
     * @param carrotPointBank
     */
    @Override
    public void updateBankActivityYn(CarrotPointBank carrotPointBank) {
        logger.info("updateBankActivityYn");
        this.getSqlSession().update("CARROTPOINT_BANK.updateBankActivityYn", carrotPointBank);
    }
}
